/*
 * BattlePetResource.h
 *
 *  Created on: 2013. 11. 5.
 *      Author: mega@gamevil.com
 */

#ifndef BATTLEPETRESOURCE_H_
#define BATTLEPETRESOURCE_H_

#include <map>

namespace ProjectZ { namespace NResource {

class BattlePetResource
{
public:
	struct Key
	{
		Key() : type(0), sub_type(0) {}
		Key(int rType, int rSubType) : type(rType), sub_type(rSubType) {}

		int type;
		int sub_type;

		bool operator == (const Key & rSide) const
		{
			if (this->type == rSide.type && this->sub_type == rSide.sub_type)
				return true;

			return false;
		}

		bool operator < (const Key & rSide) const
		{
			if (this->type < rSide.type)
			{
				return true;
			}
			else if (this->type == rSide.type)
			{
				if (this->sub_type < rSide.sub_type)
					return true;
			}

			return false;
		}
	};

public:
	struct Flyweight
	{
		int _CHAR_TID;
		int _ITEM_TID;
		int _BATTLE_TYPE;
		int _PET_DGREE;
		int _PET_VERSION;
		int _PET_OPEN_LEVEL;
	};

public:
	typedef std::map<Key, Flyweight *> BATTLEPETTREE;

public:
	BattlePetResource();
	virtual ~BattlePetResource();

	bool LoadResource();
	Flyweight * GetFly(Key & clsKey);

	BATTLEPETTREE & GetTree() { return clsFlyTree; }

private:
	void	Clear();

private:
	BATTLEPETTREE clsFlyTree;
};

} /* NResource */ } /* ProjectZ */


#endif /* BATTLEPETRESOURCE_H_ */
